package com.trade.wzj.service.xiang;


import com.trade.wzj.dao.xiang.ProductInfoQuotaDao;
import com.trade.wzj.model.xiang.ProductInfoQuota;

public class ProductInfoQuotaimpl implements ProductInfoQuotaService {
	private ProductInfoQuotaDao mapper;

	public ProductInfoQuotaDao getMapper() {
		return mapper;
	}

	public void setMapper(ProductInfoQuotaDao mapper) {
		this.mapper = mapper;
	}

	/*
	 * (non-Javadoc)供应商产品信息添加
	 * 
	 * @see
	 * com.trade.wzj.service.xiang.ProductInfoQuotaService#ProductInfoQuotaAdd(com.
	 * trade.wzj.model.xiang.ProductInfoQuota)
	 */
	@Override
	public boolean ProductInfoQuotaAdd(ProductInfoQuota productinfoquota) throws Exception {
		String productPrice = String.valueOf(productinfoquota.getProductPrice());
		String rental = String.valueOf(productinfoquota.getRental());
		if (productinfoquota.getProductName().equals("")) {
			try {
				throw new Exception("不能为空");
			} catch (Exception e) {
				e.printStackTrace();
			}
		} else if (productinfoquota.getProductNum() == null) {
			try {
				throw new Exception("不能为空");
			} catch (Exception e) {
				e.printStackTrace();
			}
		} else if (productinfoquota.getUnit().equals("")) {
			try {
				throw new Exception("不能为空");
			} catch (Exception e) {
				e.printStackTrace();
			}
		} else if (productinfoquota.getSupplierquotaID() == null) {
			try {
				throw new Exception("不能为空");
			} catch (Exception e) {
				e.printStackTrace();
			}
		} else if (productPrice.equals("")) {
			try {
				throw new Exception("不能为空");
			} catch (Exception e) {
				e.printStackTrace();
			}
		} else if (productinfoquota.getExpirationDates() == null) {
			try {
				throw new Exception("不能为空");
			} catch (Exception e) {
				e.printStackTrace();
			}
		} else if (rental.equals("")) {
			try {
				throw new Exception("不能为空");
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
		int result = 0;
		try {
			result = mapper.ProductInfoQuotaAdd(productinfoquota);
			if (result > 0) {
				System.out.println("添加成功");
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		return true;
	}

	/*
	 * (non-Javadoc)供应商产品信息删除id
	 * 
	 * @see
	 * com.trade.wzj.service.xiang.ProductInfoQuotaService#ProductInfoQuotaDel(int)
	 */
	@Override
	public boolean ProductInfoQuotaDel(int productInfoQuotaID) throws Exception {
		int res = 0;
		try {
			res = mapper.ProductInfoQuotaDel(productInfoQuotaID);
			if (res > 0) {
				System.out.println("删除成功");
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		return true;
	}

	@Override
	public ProductInfoQuota ProductInfoQuotaSel(Integer productInfoQuotaID) throws Exception {
		ProductInfoQuota list = mapper.ProductInfoQuotaSel(productInfoQuotaID);
		return list;
	}
}
